package com.xh.lesson.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xh.lesson.entity.TEnterprise;
import com.xh.lesson.mapper.TEnterprisedMapper;
import com.xh.lesson.service.TEnterpriseService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 柴&许
 * @since 2021-06-23
 */
@Service
public class TEnterpriseServiceImpl extends ServiceImpl<TEnterprisedMapper, TEnterprise> implements TEnterpriseService {

    @Override
    public TEnterprise selectEnterprise(Integer id) {

        TEnterprise select = baseMapper.selectById(id);
        if(select.getParentid()==0) {
            return select;
        }
        TEnterprise tEnterprise = baseMapper.selectById(select.getParentid());

        return tEnterprise;
    }

    @Override
    public TEnterprise selectEnterpriseClassOne(Integer id) {

        TEnterprise select = baseMapper.selectById(id);
        if(select.getParentid()!=0){
            return select;
        }
        return null;
    }

    @Override
    public List<TEnterprise> selectAllEnterpriseClass(String enterprisename) {
        QueryWrapper<TEnterprise> wrapper = new QueryWrapper<>();
        wrapper.eq("enterprisename",enterprisename);
        TEnterprise one = baseMapper.selectOne(wrapper);

        QueryWrapper<TEnterprise> wrapper1 = new QueryWrapper<>();
        wrapper.eq("parentid",one.getEnterpriseid());

        List<TEnterprise> enterprises = baseMapper.selectList(wrapper1);
        return enterprises;
    }

    @Override
    public List<TEnterprise> selectAllEnterprise() {
        return null;
    }

    @Override
    public void addTEnterpriseClass(TEnterprise enterprise) {

    }

    @Override
    public void addTEnterprise(TEnterprise enterprise) {

    }

    @Override
    public void updateTEnterprise(TEnterprise enterprise) {

    }

    @Override
    public void deletedById(Integer id) {

    }
}
